package LCR;

public class isPalindrom {
    public static void main(String[] args) {
        System.out.println(isPalindrome("A man, a plan, a canal: Panama"));
    }
    public static boolean isPalindrome(String s) {


        StringBuffer res = new StringBuffer();
        for(char x : s.toCharArray()) {
            if(x>= 'A' && x <= 'Z' || x >= 'a' && x <= 'z' || x >='0' && x<='9') {
                x = (char) (x - ('a'- 'A'));


                res.append(x);
            }
        }
        int len = res.length();
        int left = 0;
        int right = len -1;
        while(left < right) {
            if(res.charAt(left) != res.charAt(right)) {
                return false;
            }
            left++;
            right--;
        }
        return true;

    }
}
